${page.setTitle("push-center| GOPS")}
<style type="text/css">
    .l-table-edit {}
    .l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-reset{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
</style>
${token()}
<div class="body-pla-content">
  <form action="" method="post" id="channel" name="channel">
        <table class="l-table-edit" >
            <tr>
                <td align="right" >渠道的app_id：</td>
                <td align="left" >
						<input name="appId" type="text" id="appId"  maxlength="30" value=""  validate="{required:true,maxlength:30}"/>
				</td>
				<td align="right" >是否启用：</td>
                <td align="left" >
               			 <select name="status" id="status"  enum="template.status">
						</select>
				</td>
			 </tr> 
			 <tr>
			 	<td align="right" >外部应用ID：</td>
                 <td align="left" >
                	<input name="extAppId" type="text" id="extAppId" maxlength="30" value=""  validate="{required:true,maxlength:30}"/>
				</td>
			 </tr> 
			  <tr>
                <td align="right" >渠道：</td>
                <td align="left" >
						<select name="appChannel" id="appChannel"  enum="channels.type" style="width:135px">
						</select>
				</td>
				<td align="right" >渠道名称：</td>
                <td align="left" >
					<input type="text" name="name" id="name"/>
				</td>
			 </tr> 
             <tr>
				 <td align="right" >备注：</td>
                <td align="left" colspan=3>
                <textarea rows="3" cols="60" name="memo" id="memo" ></textarea>
				</td>
            </tr>  
            <tr>
            	<td></td>
            	<td colspan=3> <input type="button" value="新增" id="dosubmit" class="l-button l-button-submit"/>  </td>
            	<td align="left"></td>
            </tr>
        </table>
    </form>
</div>

<script type="text/javascript">

$(function () {
	epay_enum.iniSelect();
	$("#dosubmit").click(function(){
		var appchannel=$("#appChannel").val();
	//	if(appchannel==undefined || appchannel=="" || appchannel==null){  
    	//	 alert("appchannel为空");  
    		// return;
		//}  
		
		var queryString = $('#channel').serializeArray(); 
		
		//for(var i=0;i<queryString.length;i++){alert(queryString[i].name+">>"+queryString[i].value); }
		//retrun;
		
	    $.ajax({
	        url: "${appServer}/channel/add.json",   
	        data: queryString, 
	        type: "POST",
	        success: function(result) {
	        	if(result.hasError) {
					$.ligerDialog.error(result.message);
	        	}else{
	        		$.ligerDialog.success(result.message);
	        		parent.window.search();
	        		parent.$.ligerDialog.close();
	        		parent.$.ligerDialog.hide();
	        	}
	        }
	    });	
		return true;
	});
	
});
//-----------------------------------guser------------------
  $(function ()
        { 
            $("#appId").ligerComboBox({
                onBeforeOpen: f_selectContact, width:135
            });
        });
        function f_selectContact()
        {
            $.ligerDialog.open({ title: ' ++选择APP_ID', name:'winselector',width: 550, height: 400,  url: '${appServer}/channel/listall', buttons: [
                { text: '确定', onclick: f_selectContactOK },
                { text: '取消', onclick: f_selectContactCancel }
            ]
            });
            return false;
        }
        function f_selectContactOK(item, dialog)
        {
			var fn = dialog.frame.f_select || dialog.frame.window.f_select; 
            var data = fn(); 
            if (!data)
            {
                alert('请选择行!');
                return;
            }
            $("#appId").val(data.partnerId);
            dialog.close();
        }
        function f_selectContactCancel(item, dialog)
        {
            dialog.close();
        }
	
		

</script>